<template>
    <div>
        <h1>父组件</h1>
        <h3>接收到的子组件的数据：{{ msg }}</h3>
        <h3>父组件的count: {{ count }}</h3>
        <ChildComponent @getData="getData" @setCount="setCount" />
    </div>
</template>

<script setup>
import { ref } from 'vue';
import ChildComponent from './ChildComponent.vue';
const msg = ref('');
const count = ref(0);

// 获取子组件的数据
function getData(data) {
    console.log("接收到的数据", data);
    msg.value = data;
}

function setCount() {
    count.value++;
}
</script>

<style scoped></style>